package com.yanfan.ccapi.service.impl;

import com.yanfan.ccapi.service.ICcapiFunctionMappingService;
import com.yanfan.ccapicode.dao.FunctionMappingRepository;
import com.yanfan.ccapicode.dao.entity.FunctionMappingDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;

/**
 * 产品功能属性映射Service业务层处理
 *
 * @author kerwincui
 * @date 2025-06-29
 */
@Service
public class CcapiFunctionMappingServiceImpl implements ICcapiFunctionMappingService {
    @Autowired
    private FunctionMappingRepository ccapiFunctionMappingMapper;

    /**
     * 查询产品功能属性映射
     *
     * @param id 产品功能属性映射主键
     * @return 产品功能属性映射
     */
    @Override
    public FunctionMappingDO selectCcapiFunctionMappingById(Long id) {
        return ccapiFunctionMappingMapper.selectCcapiFunctionMappingById(id);
    }

    /**
     * 查询产品功能属性映射列表
     *
     * @param ccapiFunctionMapping 产品功能属性映射
     * @return 产品功能属性映射
     */
    @Override
    public List<FunctionMappingDO> selectCcapiFunctionMappingList(FunctionMappingDO ccapiFunctionMapping) {
        return ccapiFunctionMappingMapper.selectCcapiFunctionMappingList(ccapiFunctionMapping);
    }

    /**
     * 新增产品功能属性映射
     *
     * @param ccapiFunctionMapping 产品功能属性映射
     * @return 结果
     */
    @Override
    public boolean insertCcapiFunctionMapping(FunctionMappingDO ccapiFunctionMapping) {
        ccapiFunctionMapping.setCreateTime(LocalDateTime.now());
        return ccapiFunctionMappingMapper.insertOrUpdate(ccapiFunctionMapping);
    }

    /**
     * 修改产品功能属性映射
     *
     * @param ccapiFunctionMapping 产品功能属性映射
     * @return 结果
     */
    @Override
    public boolean updateCcapiFunctionMapping(FunctionMappingDO ccapiFunctionMapping) {
        ccapiFunctionMapping.setUpdateTime(LocalDateTime.now());
        return ccapiFunctionMappingMapper.insertOrUpdate(ccapiFunctionMapping);
    }

    /**
     * 批量删除产品功能属性映射
     *
     * @param ids 需要删除的产品功能属性映射主键
     * @return 结果
     */
    @Override
    public boolean deleteCcapiFunctionMappingByIds(Long[] ids) {
        return ccapiFunctionMappingMapper.deleteByIds(Arrays.asList(ids));
    }

    /**
     * 删除产品功能属性映射信息
     *
     * @param id 产品功能属性映射主键
     * @return 结果
     */
    @Override
    public boolean deleteCcapiFunctionMappingById(Long id) {
        return ccapiFunctionMappingMapper.deleteById(id);
    }
}
